package kr.hkit.powerjava.chapter22.submit;

public class Student implements Comparable<Student>{
	private int stdNum;
	private String stdName;
	private int KorScore;
	private int engScore;
	private int mathScore;
	
	// 생성자는 학번, 성명만  혹은 다 받을 수도 있고 
	public Student(int stdNum, String stdName) {
		this.stdNum = stdNum;
		this.stdName = stdName;
	}
	
	public Student(int stdNum, String stdName, int korScore, int engScore,
			int mathScore) {
		this.stdNum = stdNum;
		this.stdName = stdName;
		KorScore = korScore;
		this.engScore = engScore;
		this.mathScore = mathScore;
	}

	public Student() {
	}

	public int getStdNum() {
		return stdNum;
	}

	public void setStdNum(int stdNum) {
		this.stdNum = stdNum;
	}

	public String getStdName() {
		return stdName;
	}

	public void setStdName(String stdName) {
		this.stdName = stdName;
	}

	public int getKorScore() {
		return KorScore;
	}

	public void setKorScore(int korScore) {
		KorScore = korScore;
	}

	public int getEngScore() {
		return engScore;
	}

	public void setEngScore(int engScore) {
		this.engScore = engScore;
	}

	public int getMathScore() {
		return mathScore;
	}

	public void setMathScore(int mathScore) {
		this.mathScore = mathScore;
	}
	
	
	
	public int totalScore () { //총점
		return KorScore + mathScore + engScore;
	}
	
	public double toalAvg () { //평균
		return totalScore() / 3.0;		
	}

	
	
	@Override
	public boolean equals(Object obj) { // 이거 해줘야 함!!
//		return stdName.equals(((Student)obj).stdName); //이름 검색
//		return stdNum==((Student)obj).stdNum; //학번 검색
		
		return stdNum==((Student)obj).stdNum && stdName.equals(((Student)obj).stdName);
		//and 써서 학번 이름 둘다 조건 줄 수 있음 
	}
	
	@Override
	public String toString() {
		return String
				.format("%3s\t%4s\t%4s\t%4s\t%4s\t%4s\t%5.2f",
						stdNum, stdName, KorScore, engScore, mathScore,
						totalScore(), toalAvg());
	}

	@Override
	public int compareTo(Student o) { //총점가지고 정렬
		return o.totalScore() - totalScore();
	}
}



